//
//  ZYCTeachingLearnDetailCellView.m
//  ZDSC
//
//  Created by ZDTX on 2021/9/2.
//

#import "ZYCTeachingLearnDetailCellView.h"
#import "ZYCTeachLearningDetailModel.h"

@interface ZYCTeachingLearnDetailCellView ()

@property (nonatomic, strong) UIImageView *statusImageView;
@property (nonatomic, strong) UILabel *titleLabel;

@end
@implementation ZYCTeachingLearnDetailCellView

-(void) setSelected:(BOOL)selected{
    _selected = selected;
    if (selected) {//选中
        if (self.subjectType == 1) { //单选题
            _statusImageView.image = [UIImage imageNamed:@"xz"];
        }else{// 多选题
            _statusImageView.image = [UIImage imageNamed:@"fxz"];
        }
    }else{// 未选中
        if (self.subjectType == 1) {// 单选题
            _statusImageView.image = [UIImage imageNamed:@"wxx"];
        }else{ // 多选题
            _statusImageView.image = [UIImage imageNamed:@"xzz"];
        }
    }
    
}
//subjectType 题目类型（1：单选题；2：多选题；3：简答题）
- (void)setSubjectType:(NSInteger)subjectType{
    _subjectType = subjectType;
    if (subjectType == 1) {
        _statusImageView.image = [UIImage imageNamed:@"wxx"];
    }else{
        _statusImageView.image = [UIImage imageNamed:@"xzz"];
    }
}

- (void)setModel:(ZYCDetailAnswerModel *)model{
    _model = model;
    _titleLabel.text = [NSString stringWithFormat:@"%@ (%@人)",model.content,model.answerCount];
}


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.statusImageView];
        [self addSubview:self.titleLabel];
        [self.statusImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(15.0f);
            make.centerY.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(14.0f, 14.0f));
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.equalTo(self);
            make.right.equalTo(self);
            make.left.equalTo(self.statusImageView.mas_right).offset(5.0f);
        }];
    }
    return self;
}

- (UIImageView *)statusImageView {
    if (!_statusImageView) {
        _statusImageView = [[UIImageView alloc] init];
    }
    return _statusImageView;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 16.0f) titleColor:HEX_RGB(@"#999999") textAlignment:ZZTextAlignmentLeft];
        _titleLabel.numberOfLines = 0;
    }
    return _titleLabel;
}

@end
